<template>
    <div class="editUser">
        <h1 style="margin:20px;">查看用户信息</h1>
        <el-form :model="user" label-width="120px">
          <el-form-item label="姓名">
            <el-input v-model="user.username" readonly/>
          </el-form-item>
          <el-form-item label="电话">
            <el-input v-model="user.phone" type="text" readonly/>
          </el-form-item>
          <el-form-item label="身份权限">
            <el-input v-model="user.permissions" type="text" readonly/>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="()=>{$router.push(`/userlist`)}" class="btn">返回</el-button>
          </el-form-item>
        </el-form>
    </div>
</template>

<script>
import {reqUserById} from '../../../api/index';
export default {
    name:'EditUser',
    data(){
        return {
            user:{
                username:'',
                phone:'',
                permissions:''
            }
        }
    },
    methods:{
        async showUser(){
            let res = await reqUserById(this.$route.params.id);
            console.log(res);
            this.user.username = res.user.name;
            this.user.phone = res.user.phone;
            this.user.permissions = res.user.permissions;
            this.user.id_card = res.user.id_card;
        }
    },
    mounted(){
        this.showUser();
    }
}
</script>

<style>

</style>